#include "head.h"
int do_worker(int net_fd){
    while(1){
        //接收命令
        printf("work\n");
        /* char cmd[100]; */
        /* recv(net_fd,cmd,sizeof(cmd),0); */
        /* printf("%s\n",cmd); */
        /* if(strcmp(cmd,"up") == 0){ */
        /*     sign_up(net_fd); */
        /*     continue; */
        /* }else if(strcmp(cmd,"in") == 0){ */
        /*     //sign_in(net_fd); */
        /* } */
        command_t* command=(command_t*)calloc(1,sizeof(command_t));
        /* char cut_buf[1000]={0}; */
        
        //接收buf
        recv(net_fd,command->buf,sizeof(command->buf),0); 
        /* printf("command->buf=%s\n",command->buf); */
        
        char* comd=strtok(command->buf,"&");
        /* printf("comd=%s\n",comd); */
        command->path=strtok(NULL," \n");
        /* printf("path=%s\n",command->path); */
        char* cmds=strtok(comd," \n");
/* printf("cmds: %s\n", cmds); */
        char* arg[10];
        int arg_count=0;
        while ((arg[arg_count] = strtok(NULL, " \n")) != NULL) {
            arg_count++;
            }
        //命令参数的个数
        command->token_num=arg_count;



        if(strcmp(cmds,"cd")==0){
            //todo,执行cd函数
            changedir(command, arg[0], net_fd);
        }else if(strcmp(cmds,"ls")==0){
            //todo
        }else if(strcmp(cmds,"puts")==0){
            command_puts(command,net_fd);
        }else if(strcmp(cmds,"gets")==0){
            //todo
        }else if(strcmp(cmds,"rm")==0){
            //todo
        }else if(strcmp(cmds,"pwd")==0){
            //todo
        }else{
            char error_msg[100]={0};
            recv(net_fd,error_msg,sizeof(error_msg),0);
            LOG_MSG(INFO,error_msg);
            //todo，打印到日志
        }

    }    
    return 0;
}
